package cn.cjxy.javaweb.servlet.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 取值
 *
 * RequestDispatcher也可以将这个请求的结果包含到此次请求中；
 * ● forward(ServletRequest request, ServletResponse Response)：将请求跳转到分发器指定的地方；
 * ● include(ServletRequest request, ServletResponse Response)：收集分发器指定的请求的响应结果；
 * @author huangjie
 * @date 2025/9/29
 */
@WebServlet("/reqDemo3-2")
public class RequestDemo3_2 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter writer = resp.getWriter();
        //取值
        String user = (String) req.getAttribute("user");
        writer.println("在3-2中取出user值为--"+user);
    }
}
